package comparator;

import container.LinkedList;

public class ShellSort<T> {

	public void sort(LinkedList<T> list, Comparator<T> comparator){
		
		int inc = Math.round(list.size()/ 2);
		int j;
		
		while( inc > 0 ){
			for(int i = inc; i < list.size() ; i++){
				
				j = i;
				T temp = list.get(i);
				
				while(( j >= inc) && (comparator.compare(temp, list.get(j - inc)) < 0)){
					list.switchObjects(j - inc, j);
					j = j - inc;
				}
			}
			inc = (int) Math.round(inc / 2.2);

		}
	}
}
